<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">




<title>C#.NET编程----Spring.NET &amp; NHibernate整合(一) - Spring.Net &amp; NHibernate 技术中文站 - 博客园</title>
<meta name="keywords" content="我的随笔,C#.NET编程,Spring.NET,NHibernate整合">
<meta name="description" content="C#.NET编程----Spring.NET &amp; NHibernate整合(一) --Spring.NET入门这是一个简单的Spring.NET的例子。如果你还没有玩过Spring.NET，你一定要看一下这篇文章。他会告诉你怎么在项目中使用Spring.NET的IOC。">



<link title="RSS" type="application/rss+xml" rel="alternate" href="http://www.cnblogs.com/it1630/rss">
<link title="RSD" type="application/rsd+xml" rel="EditURI" href="http://www.cnblogs.com/it1630/rsd.xml"> 
  



<link rel="stylesheet" type="text/css" href="index.css" media="all">
</head>
<body>
    <form name="Form1" method="post" action="http://www.cnblogs.com/it1630/archive/2006/12/01/579059.html" id="Form1">
<div>
<input name="__EVENTTARGET" id="__EVENTTARGET" value="" type="hidden">
<input name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" type="hidden">
<input name="__VIEWSTATE" id="__VIEWSTATE" value="" type="hidden">
</div>




        <div align="center">
<ins style="border: medium none ; margin: 0pt; padding: 0pt; display: inline-table; height: 90px; position: relative; visibility: visible; width: 728px;"><ins style="border: medium none ; margin: 0pt; padding: 0pt; display: block; height: 90px; position: relative; visibility: visible; width: 728px;"><iframe allowtransparency="true" hspace="0" id="google_ads_frame1" marginheight="0" marginwidth="0" name="google_ads_frame" src="index_1.html" style="left: 0pt; position: absolute; top: 0pt;" vspace="0" scrolling="no" frameborder="0" height="90" width="728"></iframe></ins></ins>
</div>
<div id="maincontainer">
	<div id="header">
		
<h1><a id="Header1_HeaderTitle" class="headermaintitle" href="http://www.cnblogs.com/it1630/">Spring.Net &amp; NHibernate 技术中文站</a></h1>
<div id="tagline"><span>Spring.NET &amp; NHibernate of C#.NET 技术论坛 <a href="http://www.springframework.cn/" class="smarterwiki-linkify">http://www.springframework.cn/</a></span></div>
<div id="menubar">
<div id="blogstats">
<span>posts(32)</span>
<span>comments(146)</span>
<span>trackbacks(5)</span>

</div>
<ul>
	<li><a id="Header1_MyLinks1_HomeLink" class="home" href="http://www.cnblogs.com/">博客园</a></li>
	<li><a id="Header1_MyLinks1_ContactLink" accesskey="9" class="contact" href="http://space.cnblogs.com/msg/send/%e3%8a%a3%e9%98%bf%e5%8d%8e">联系</a></li>
	<li><a id="Header1_MyLinks1_XMLLink" href="http://www.cnblogs.com/it1630/rss"><img src="xmlsmall.gif" alt="订阅" style="border-width: 0px;"></a>&nbsp;<a id="Header1_MyLinks1_Syndication" href="http://www.cnblogs.com/it1630/rss">订阅</a></li>
	<li><a id="Header1_MyLinks1_Admin" class="admin" href="http://www.cnblogs.com/it1630/admin/EditPosts.aspx">管理</a></li>		
</ul></div>




	</div>
	<div id="content">
		<div id="left" style="display: inline;">
			
				
<div class="container">
	<div class="containerheader"><h3>News</h3></div>
	<div class="containercontent">
		FastSpring技术支持论坛: <br>
<a href="http://www.springframework.cn/index.php" target="_top">www.springframework.cn</a> 


<div id="profile_block"><a href="http://home.cnblogs.com/it1630/" target="_top">我的主页</a>&nbsp; <a href="http://home.cnblogs.com/it1630/detail/" target="_top">个人资料</a><br><a href="http://home.cnblogs.com/it1630/ing/" target="_top">我的闪存</a>&nbsp; <a href="http://space.cnblogs.com/msg/send/%e3%8a%a3%e9%98%bf%e5%8d%8e" target="_top">发短消息</a></div>
	</div>
</div>

				
				

<div class="container">
<div class="containerheader">
<h3 class="catListTitle">搜索</h3>
</div>
<div class="containercontent">
<div class="div_my_zzk"><input value="" id="q" onkeydown="return zzk_go_enter(event);" class="input_my_zzk" type="text">&nbsp;<input onclick="zzk_go()" value="找找看" id="btnZzk" class="btn_my_zzk" type="button"></div>
</div>
</div>
<div class="container">
	<div class="containerheader">
<h3>常用链接</h3>
</div>
<div class="containercontent">
<ul>
		<li><a id="SingleColumn_ctl02_repeaterLinks_ctl01_lnkLinkItem" href="http://www.cnblogs.com/it1630/OtherPosts.html">我的参与</a></li>
	
		<li><a id="SingleColumn_ctl02_repeaterLinks_ctl02_lnkLinkItem" href="http://www.cnblogs.com/it1630/MyNews.html">我的新闻</a></li>
	
		<li><a id="SingleColumn_ctl02_repeaterLinks_ctl03_lnkLinkItem" href="http://www.cnblogs.com/it1630/RecentComments.html">最新评论</a></li>
	
		<li><a id="SingleColumn_ctl02_repeaterLinks_ctl04_lnkLinkItem" href="http://www.cnblogs.com/it1630/tag/">我的标签</a></li>
	</ul>
</div>
</div>

<div class="container">
<div class="containerheader">
<h3>我的标签</h3>
</div>
<div class="containercontent">
<div id="MyTag">
<ul>
<li><a href="http://www.cnblogs.com/it1630/tag/Spring.NET/">Spring.NET</a>(6)</li><li><a href="http://www.cnblogs.com/it1630/tag/NHibernate/">NHibernate</a>(6)</li><li><a href="http://www.cnblogs.com/it1630/tag/FastSpring.NET/">FastSpring.NET</a>(5)</li><li><a href="http://www.cnblogs.com/it1630/tag/C%23/">C#</a>(4)</li><li><a href="http://www.cnblogs.com/it1630/tag/.NET/">.NET</a>(4)</li><li><a href="http://www.cnblogs.com/it1630/tag/%e4%ba%ba%e8%84%89%e9%80%9a/">人脉通</a>(3)</li><li><a href="http://www.cnblogs.com/it1630/tag/ProjectOffice/">ProjectOffice</a>(3)</li><li><a href="http://www.cnblogs.com/it1630/tag/PMS/">PMS</a>(2)</li><li><a href="http://www.cnblogs.com/it1630/tag/%e9%98%bf%e9%87%8c%e5%b7%b4%e5%b7%b4/">阿里巴巴</a>(2)</li><li><a href="http://www.cnblogs.com/it1630/tag/Ajax/">Ajax</a>(2)</li><li><a href="http://www.cnblogs.com/it1630/tag/">更多</a></li>
</ul>
</div>
</div>
</div>
		<div class="container">
			<div class="containerheader"><h3>随笔分类<span style="font-size: 11px; font-weight: normal;">(38)</span></h3></div>
			
					<ul class="containercontent">
				
					<li><a id="SingleColumn_Categories_CatList_ctl00_LinkList_ctl01_RssLink" title="Subscribe to 精通篇(13)" class="rsslink" href="http://www.cnblogs.com/it1630/category/78360.html/rss"></a><a id="SingleColumn_Categories_CatList_ctl00_LinkList_ctl01_Link" href="http://www.cnblogs.com/it1630/category/78360.html">精通篇(13)</a></li>
				
					<li><a id="SingleColumn_Categories_CatList_ctl00_LinkList_ctl02_RssLink" title="Subscribe to 入门篇(5)" class="rsslink" href="http://www.cnblogs.com/it1630/category/78358.html/rss"></a><a id="SingleColumn_Categories_CatList_ctl00_LinkList_ctl02_Link" href="http://www.cnblogs.com/it1630/category/78358.html">入门篇(5)</a></li>
				
					<li><a id="SingleColumn_Categories_CatList_ctl00_LinkList_ctl03_RssLink" title="Subscribe to 提高篇(9)" class="rsslink" href="http://www.cnblogs.com/it1630/category/78359.html/rss"></a><a id="SingleColumn_Categories_CatList_ctl00_LinkList_ctl03_Link" href="http://www.cnblogs.com/it1630/category/78359.html">提高篇(9)</a></li>
				
					<li><a id="SingleColumn_Categories_CatList_ctl00_LinkList_ctl04_RssLink" title="Subscribe to 我的随笔(11)" class="rsslink" href="http://www.cnblogs.com/it1630/category/77467.html/rss"></a><a id="SingleColumn_Categories_CatList_ctl00_LinkList_ctl04_Link" href="http://www.cnblogs.com/it1630/category/77467.html">我的随笔(11)</a></li>
				
					</ul>
				
			<div class="containerfooter"></div>
		</div>		
	
		<div class="container">
			<div class="containerheader"><h3>随笔档案<span style="font-size: 11px; font-weight: normal;">(32)</span></h3></div>
			
					<ul class="containercontent">
				
					<li><a id="SingleColumn_Categories_CatList_ctl01_LinkList_ctl01_Link" href="http://www.cnblogs.com/it1630/archive/2009/09.html">2009年9月 (3)</a></li>
				
					<li><a id="SingleColumn_Categories_CatList_ctl01_LinkList_ctl02_Link" href="http://www.cnblogs.com/it1630/archive/2009/08.html">2009年8月 (3)</a></li>
				
					<li><a id="SingleColumn_Categories_CatList_ctl01_LinkList_ctl03_Link" href="http://www.cnblogs.com/it1630/archive/2009/06.html">2009年6月 (1)</a></li>
				
					<li><a id="SingleColumn_Categories_CatList_ctl01_LinkList_ctl04_Link" href="http://www.cnblogs.com/it1630/archive/2009/05.html">2009年5月 (2)</a></li>
				
					<li><a id="SingleColumn_Categories_CatList_ctl01_LinkList_ctl05_Link" href="http://www.cnblogs.com/it1630/archive/2009/04.html">2009年4月 (1)</a></li>
				
					<li><a id="SingleColumn_Categories_CatList_ctl01_LinkList_ctl06_Link" href="http://www.cnblogs.com/it1630/archive/2008/05.html">2008年5月 (1)</a></li>
				
					<li><a id="SingleColumn_Categories_CatList_ctl01_LinkList_ctl07_Link" href="http://www.cnblogs.com/it1630/archive/2008/04.html">2008年4月 (2)</a></li>
				
					<li><a id="SingleColumn_Categories_CatList_ctl01_LinkList_ctl08_Link" href="http://www.cnblogs.com/it1630/archive/2008/02.html">2008年2月 (1)</a></li>
				
					<li><a id="SingleColumn_Categories_CatList_ctl01_LinkList_ctl09_Link" href="http://www.cnblogs.com/it1630/archive/2008/01.html">2008年1月 (2)</a></li>
				
					<li><a id="SingleColumn_Categories_CatList_ctl01_LinkList_ctl10_Link" href="http://www.cnblogs.com/it1630/archive/2007/11.html">2007年11月 (1)</a></li>
				
					<li><a id="SingleColumn_Categories_CatList_ctl01_LinkList_ctl11_Link" href="http://www.cnblogs.com/it1630/archive/2007/10.html">2007年10月 (1)</a></li>
				
					<li><a id="SingleColumn_Categories_CatList_ctl01_LinkList_ctl12_Link" href="http://www.cnblogs.com/it1630/archive/2007/09.html">2007年9月 (1)</a></li>
				
					<li><a id="SingleColumn_Categories_CatList_ctl01_LinkList_ctl13_Link" href="http://www.cnblogs.com/it1630/archive/2007/08.html">2007年8月 (3)</a></li>
				
					<li><a id="SingleColumn_Categories_CatList_ctl01_LinkList_ctl14_Link" href="http://www.cnblogs.com/it1630/archive/2007/06.html">2007年6月 (3)</a></li>
				
					<li><a id="SingleColumn_Categories_CatList_ctl01_LinkList_ctl15_Link" href="http://www.cnblogs.com/it1630/archive/2006/12.html">2006年12月 (6)</a></li>
				
					<li><a id="SingleColumn_Categories_CatList_ctl01_LinkList_ctl16_Link" href="http://www.cnblogs.com/it1630/archive/2006/11.html">2006年11月 (1)</a></li>
				
					</ul>
				
			<div class="containerfooter"></div>
		</div>		
	
		<div class="container">
			<div class="containerheader"><h3>文章分类<span style="font-size: 11px; font-weight: normal;">(2)</span></h3></div>
			
					<ul class="containercontent">
				
					<li><a id="SingleColumn_Categories_CatList_ctl02_LinkList_ctl01_RssLink" title="Subscribe to 精通篇" class="rsslink" href="http://www.cnblogs.com/it1630/category/77462.html/rss"></a><a id="SingleColumn_Categories_CatList_ctl02_LinkList_ctl01_Link" href="http://www.cnblogs.com/it1630/category/77462.html">精通篇</a></li>
				
					<li><a id="SingleColumn_Categories_CatList_ctl02_LinkList_ctl02_RssLink" title="Subscribe to 入门篇(1)" class="rsslink" href="http://www.cnblogs.com/it1630/category/77460.html/rss"></a><a id="SingleColumn_Categories_CatList_ctl02_LinkList_ctl02_Link" href="http://www.cnblogs.com/it1630/category/77460.html">入门篇(1)</a></li>
				
					<li><a id="SingleColumn_Categories_CatList_ctl02_LinkList_ctl03_RssLink" title="Subscribe to 提高篇(1)" class="rsslink" href="http://www.cnblogs.com/it1630/category/77461.html/rss"></a><a id="SingleColumn_Categories_CatList_ctl02_LinkList_ctl03_Link" href="http://www.cnblogs.com/it1630/category/77461.html">提高篇(1)</a></li>
				
					</ul>
				
			<div class="containerfooter"></div>
		</div>		
	
		<div class="container">
			<div class="containerheader"><h3>文章档案<span style="font-size: 11px; font-weight: normal;">(2)</span></h3></div>
			
					<ul class="containercontent">
				
					<li><a id="SingleColumn_Categories_CatList_ctl03_LinkList_ctl01_Link" href="http://www.cnblogs.com/it1630/archives/2006/11.html">2006年11月 (2)</a></li>
				
					</ul>
				
			<div class="containerfooter"></div>
		</div>		
	
		<div class="container">
			<div class="containerheader"><h3>合作站点</h3></div>
			
					<ul class="containercontent">
				
					<li><a id="SingleColumn_Categories_CatList_ctl04_LinkList_ctl01_Link" href="http://www.51itsp.com/">ProjectOffice 项目管理</a></li>
				<li style="margin-top: 2px;">ProjectOffice 项目管理软件 项目管理系统</li>
					<li><a id="SingleColumn_Categories_CatList_ctl04_LinkList_ctl02_Link" href="http://www.springframework.cn/" target="_top">Spring.net技术中文站</a></li>
				<li style="margin-top: 2px;">Spring.NET &amp; NHibernate of C#.NET 技术中文论坛</li>
					<li><a id="SingleColumn_Categories_CatList_ctl04_LinkList_ctl03_Link" href="http://www.51muying.com/" target="_top">母婴网</a></li>
				<li style="margin-top: 2px;">母婴网(51muying.Com)是专业的母婴资讯网站。</li>
					<li><a id="SingleColumn_Categories_CatList_ctl04_LinkList_ctl04_Link" href="http://www.alirenmai.com/" target="_top">人脉通</a></li>
				<li style="margin-top: 2px;">阿里人脉网--阿里巴巴开心网，阿里人脉通，阿里巴巴，人脉通</li>
					<li><a id="SingleColumn_Categories_CatList_ctl04_LinkList_ctl05_Link" href="http://www.56easy.com/" target="_top">物流百科 物流知识</a></li>
				<li style="margin-top: 2px;">物流百科-物流知识|物流论文|第三方物流|物流技术|物流行业百科全书
</li>
					</ul>
				
			<div class="containerfooter"></div>
		</div>		
	


<h3 class="catListTitle">最新随笔</h3>
<div class="RecentComment" id="RecentPosts">
<ul style="">
	
	
			<li><a id="SingleColumn_ctl05_RecentPostsList_ctl00_RecentPostsList2_ctl00_Hyperlink1" href="http://www.cnblogs.com/it1630/archive/2009/09/14/1566179.html">1.&nbsp;KeyNotFoundException: 给定关键字不在字典中</a></li>
		
			<li><a id="SingleColumn_ctl05_RecentPostsList_ctl00_RecentPostsList2_ctl01_Hyperlink1" href="http://www.cnblogs.com/it1630/archive/2009/09/14/1566092.html">2.&nbsp;FastSpring.NET v4.1将使用Spring.NET1.3和NHibernate2.1</a></li>
		
		
	
			<li><a id="SingleColumn_ctl05_RecentPostsList_ctl01_RecentPostsList2_ctl00_Hyperlink1" href="http://www.cnblogs.com/it1630/archive/2009/09/12/1565605.html">3.&nbsp;FastSpring.NET v4.1 Sample 提供下载(含FastSpring.NETv4.1bin版)</a></li>
		
		
	
			<li><a id="SingleColumn_ctl05_RecentPostsList_ctl02_RecentPostsList2_ctl00_Hyperlink1" href="http://www.cnblogs.com/it1630/archive/2009/08/26/1554496.html">4.&nbsp;Spring.Net &amp; NHibernate 中文论坛重新开放！</a></li>
		
		
	
			<li><a id="SingleColumn_ctl05_RecentPostsList_ctl03_RecentPostsList2_ctl00_Hyperlink1" href="http://www.cnblogs.com/it1630/archive/2009/08/20/1550808.html">5.&nbsp;FastSpring.NET v4.0 Sample 提供下载</a></li>
		
		
	
			<li><a id="SingleColumn_ctl05_RecentPostsList_ctl04_RecentPostsList2_ctl00_Hyperlink1" href="http://www.cnblogs.com/it1630/archive/2009/08/14/1546178.html">6.&nbsp;母婴网(51muying.Com)</a></li>
		
		
	
			<li><a id="SingleColumn_ctl05_RecentPostsList_ctl05_RecentPostsList2_ctl00_Hyperlink1" href="http://www.cnblogs.com/it1630/archive/2009/06/19/1506413.html">7.&nbsp;[推荐]物流百科-物流行业百科全书</a></li>
		
		
	
			<li><a id="SingleColumn_ctl05_RecentPostsList_ctl06_RecentPostsList2_ctl00_Hyperlink1" href="http://www.cnblogs.com/it1630/archive/2009/05/28/1491380.html">8.&nbsp;今天收到阿里巴巴 人脉通体验邮件</a></li>
		
		
	
			<li><a id="SingleColumn_ctl05_RecentPostsList_ctl07_RecentPostsList2_ctl00_Hyperlink1" href="http://www.cnblogs.com/it1630/archive/2009/05/07/1451282.html">9.&nbsp;新注册了个域名alirenmai.com大家看做个什么网站好？</a></li>
		
		
	
			<li><a id="SingleColumn_ctl05_RecentPostsList_ctl08_RecentPostsList2_ctl00_Hyperlink1" href="http://www.cnblogs.com/it1630/archive/2009/04/24/1442708.html">10.&nbsp;马云涉足SNS社区? alirenmai.com正式启用</a></li>
		
	
</ul>
</div>

<div class="container">
<div class="containerheader"><h3>最新评论
	<a id="SingleColumn__1b122e90e8f1_RSSHyperlink1" href="http://www.cnblogs.com/it1630/CommentsRSS.aspx"><img src="xml.gif" style="border-width: 0px;"></a></h3></div>
	
			<ul style="" class="containercontent">
		
			<li style="">
				<a id="SingleColumn__1b122e90e8f1_CommentList_ctl01_Hyperlink1" href="http://www.cnblogs.com/it1630/archive/2009/09/12/1565605.html#1644773">1.&nbsp;Re:FastSpring.NET v4.1 Sample 提供下载(含FastSpring.NETv4.1bin版)</a>
			</li>
			<li style="">
				有这么强大吗
			</li>
			<li style="text-align: right; margin-right: 4px;">
				--jesery Liang</li>
		
			<li style="">
				<a id="SingleColumn__1b122e90e8f1_CommentList_ctl02_Hyperlink1" href="http://www.cnblogs.com/it1630/archive/2009/05/28/1491380.html#1542734">2.&nbsp;re: 今天收到阿里巴巴 人脉通体验邮件</a>
			</li>
			<li style="">
				1楼的，你不是阿里巴巴“人脉通”的体验用户，当然你觉得是骗人。
<br>
<br>我相信只要是5188体验用户之一的人，看到截图肯定知道是怎么回事！
			</li>
			<li style="text-align: right; margin-right: 4px;">
				--㊣阿华</li>
		
			<li style="">
				<a id="SingleColumn__1b122e90e8f1_CommentList_ctl03_Hyperlink1" href="http://www.cnblogs.com/it1630/archive/2009/05/28/1491380.html#1540805">3.&nbsp;re: 今天收到阿里巴巴 人脉通体验邮件</a>
			</li>
			<li style="">
				建议关了此博客，整天在骗人。
			</li>
			<li style="text-align: right; margin-right: 4px;">
				--jian11111111</li>
		
			<li style="">
				<a id="SingleColumn__1b122e90e8f1_CommentList_ctl04_Hyperlink1" href="http://www.cnblogs.com/it1630/archive/2009/05/07/1451282.html#1535079">4.&nbsp;re: 新注册了个域名alirenmai.com大家看做个什么网站好？</a>
			</li>
			<li style="">
				快捷进入阿里人脉通： <a href="http://www.cnblogs.com/it1630/archive/2006/12/01/579059.html" target="_new"></a>
			</li>
			<li style="text-align: right; margin-right: 4px;">
				--㊣阿华</li>
		
			<li style="">
				<a id="SingleColumn__1b122e90e8f1_CommentList_ctl05_Hyperlink1" href="http://www.cnblogs.com/it1630/archive/2009/04/24/1442708.html#1512673">5.&nbsp;re: 马云涉足SNS社区? alikaixin.com正式启用</a>
			</li>
			<li style="">
				我加入了！
<br>
<br><a href="http://www.cnblogs.com/it1630/archive/2006/12/01/579059.html" target="_new" rel="nofollow"></a>
			</li>
			<li style="text-align: right; margin-right: 4px;">
				--龙的传人123</li>
		
			</ul>
		
</div>

<div class="container">
<div class="containerheader"><h3>阅读排行榜</h3></div>
	
			<ul style="" class="containercontent">
		
			<li>
				<a id="SingleColumn_ctl07_TopList_ctl01_Hyperlink1" href="http://www.cnblogs.com/it1630/archive/2006/12/01/578709.html">1.&nbsp;实战C#.NET--Spring.NET &amp; NHibernate的整合(10600)</a>
			</li>
		
			<li>
				<a id="SingleColumn_ctl07_TopList_ctl02_Hyperlink1" href="http://www.cnblogs.com/it1630/archive/2006/12/01/579059.html">2.&nbsp;C#.NET编程----Spring.NET &amp; NHibernate整合(一)(8277)</a>
			</li>
		
			<li>
				<a id="SingleColumn_ctl07_TopList_ctl03_Hyperlink1" href="http://www.cnblogs.com/it1630/archive/2006/12/01/579087.html">3.&nbsp;C#.NET编程----Spring.NET &amp; NHibernate整合(三) (4117)</a>
			</li>
		
			<li>
				<a id="SingleColumn_ctl07_TopList_ctl04_Hyperlink1" href="http://www.cnblogs.com/it1630/archive/2007/11/06/950876.html">4.&nbsp;国内第一个支持Spring.NET/NHibernate/Ajax的开源的Framework(3955)</a>
			</li>
		
			<li>
				<a id="SingleColumn_ctl07_TopList_ctl05_Hyperlink1" href="http://www.cnblogs.com/it1630/archive/2006/12/01/579060.html">5.&nbsp;C#.NET编程----Spring.NET &amp; NHibernate整合(二)(3768)</a>
			</li>
		
			</ul>
		

</div>

<div class="container">
<div class="containerheader">
<h3>评论排行榜</h3>
</div>
	
			<ul style="" class="containercontent">
		
			<li>
				<a id="SingleColumn_ctl08_TopList_ctl01_Hyperlink1" href="http://www.cnblogs.com/it1630/archive/2007/08/24/868513.html">1.&nbsp;FastSpring.NET V2.05 RC1 发布[包含全部源代码](25)</a>
			</li>
		
			<li>
				<a id="SingleColumn_ctl08_TopList_ctl02_Hyperlink1" href="http://www.cnblogs.com/it1630/archive/2007/11/06/950876.html">2.&nbsp;国内第一个支持Spring.NET/NHibernate/Ajax的开源的Framework(21)</a>
			</li>
		
			<li>
				<a id="SingleColumn_ctl08_TopList_ctl03_Hyperlink1" href="http://www.cnblogs.com/it1630/archive/2006/12/05/582973.html">3.&nbsp;OASystemWeb of Spring.NET &amp; NHibernate 发布V0.1(15)</a>
			</li>
		
			<li>
				<a id="SingleColumn_ctl08_TopList_ctl04_Hyperlink1" href="http://www.cnblogs.com/it1630/archive/2006/12/01/578709.html">4.&nbsp;实战C#.NET--Spring.NET &amp; NHibernate的整合(15)</a>
			</li>
		
			<li>
				<a id="SingleColumn_ctl08_TopList_ctl05_Hyperlink1" href="http://www.cnblogs.com/it1630/archive/2006/12/01/579059.html">5.&nbsp;C#.NET编程----Spring.NET &amp; NHibernate整合(一)(14)</a>
			</li>
		
			</ul>
		
</div>

							
		</div>
		<div id="right">
			
					
<div class="container">
	<div class="containerheader"><h3>View Post</h3></div>
	<div class="containercontent">
	<div class="post">
		<h2>
			<a id="ctl03_TitleUrl" href="http://www.cnblogs.com/it1630/archive/2006/12/01/579059.html">C#.NET编程----Spring.NET &amp; NHibernate整合(一)</a>
		</h2>
		<a name="_Toc152731339"><strong><span style="font-size: 15pt; font-family: 宋体;"><br>
<br>
第一个</span><span style="font-size: 15pt; font-family: 黑体;" lang="EN">Spring.NET</span><span style="font-size: 15pt; font-family: 宋体;">的程序</span></strong></a><br>
<br>
<p><span><span><span>&nbsp;</span></span></span><strong><span>建立项目</span></strong></p>
<p><span>项目名称为：</span><span>SpringSample</span><span>，</span><span>NameSpace</span><span>为“</span><span>OKEC.Sample.Spring</span><span>”。</span></p>
<p>&nbsp;<strong><span>添加<span>HelloTest</span>类</span></strong></p>
<p><span>HelloTest.cs<br>
</span></p>
<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; font-size: 13px; width: 98%; background-color: rgb(238, 238, 238);"><span style="color: rgb(0, 0, 255);">using</span><span style="color: rgb(0, 0, 0);">&nbsp;System;<br>
</span><span style="color: rgb(0, 0, 255);">namespace</span><span style="color: rgb(0, 0, 0);">&nbsp;OKEC.Sample.Spring<br>
{<br>
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;</span><span style="color: rgb(128, 128, 128);">&lt;summary&gt;</span><span style="color: rgb(0, 128, 0);"><br>
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;HelloTest&nbsp;的摘要说明。<br>
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;</span><span style="color: rgb(128, 128, 128);">&lt;/summary&gt;</span><span style="color: rgb(128, 128, 128);"><br>
</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);">&nbsp;HelloTest<br>
&nbsp;&nbsp;&nbsp;&nbsp;{<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">&nbsp;HelloTest()<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">&nbsp;TODO:&nbsp;在此处添加构造函数逻辑<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 0);">//<br>
</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">&nbsp;Test()<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">This&nbsp;is&nbsp;Spring.NET&nbsp;Sample&nbsp;Test!</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">Please&nbsp;press&nbsp;Enter&nbsp;close&nbsp;the&nbsp;windows!</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Console.ReadLine();</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">让程序停留，回车关闭。</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>
&nbsp;&nbsp;&nbsp;&nbsp;}<br>
}<br>
</span></div>
<br>
<br>
<br>
<span style="font-size: 12pt; font-family: 宋体;"><strong>添加<span lang="EN-US">Spring.NET</span>的配置文件<br>
<br>
</strong><span style="font-size: 10.5pt; font-family: 宋体;">文件名：</span><span style="font-size: 10.5pt; font-family: 'Times New Roman';" lang="EN">Spring_bean.xml</span><span style="font-size: 10.5pt; font-family: 宋体;">，属性设置为：嵌入的资源</span><span style="font-size: 10.5pt; font-family: 'Times New Roman';" lang="EN">/</span><span style="font-size: 10.5pt; font-family: 'Times New Roman';" lang="EN"> </span><span style="font-size: 10.5pt; font-family: 'Times New Roman';" lang="EN-US">Embedded Resource<br>
<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; font-size: 13px; width: 98%; background-color: rgb(238, 238, 238);"><span style="color: rgb(0, 0, 0);">&lt;?</span><span style="color: rgb(0, 0, 0);">xml&nbsp;version</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">1.0</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">&nbsp;encoding</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">utf-8</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">?&gt;</span><span style="color: rgb(0, 0, 0);"><br>
</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">objects&nbsp;xmlns</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"><span><a href="http://www.springframework.net/" class="smarterwiki-linkify">http://www.springframework.net</a></span></span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">&nbsp;xmlns:xsi</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"><span><a href="http://www.w3.org/2001/XMLSchema-instance" class="smarterwiki-linkify">http://www.w3.org/2001/XMLSchema-instance</a></span></span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;xsi:schemaLocation</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"><span><a href="http://www.springframework.net/" class="smarterwiki-linkify">http://www.springframework.net</a>&nbsp;</span></span><span style="color: rgb(0, 0, 0);"><br>
</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;http:</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"><span><a href="http://www.springframework.net/xsd/spring-objects.xsd" class="smarterwiki-linkify">www.springframework.net/xsd/spring-objects.xsd</a>"&gt;</span></span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 255);">object</span><span style="color: rgb(0, 0, 0);">&nbsp;id</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">Hello</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">&nbsp;type</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">OKEC.Sample.Spring.HelloTest,SpringSample</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 0);">/&gt;</span><span style="color: rgb(0, 0, 0);"><br>
</span><span style="color: rgb(0, 0, 0);">&lt;/</span><span style="color: rgb(0, 0, 0);">objects</span><span style="color: rgb(0, 0, 0);">&gt;</span><span style="color: rgb(0, 0, 0);"><br>
</span></div>
<br>
<br>
<br>
<span style="font-size: 12pt; font-family: 宋体;"><strong>建立<span lang="EN-US">Spring.NET</span>的容器初始化对像<br>
<br>
</strong><span style="font-size: 10.5pt; font-family: 'Times New Roman';" lang="EN">SpringContext.cs
<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; font-size: 13px; width: 98%; background-color: rgb(238, 238, 238);"><span style="color: rgb(0, 0, 255);">using</span><span style="color: rgb(0, 0, 0);">&nbsp;System;<br>
</span><span style="color: rgb(0, 0, 255);">using</span><span style="color: rgb(0, 0, 0);">&nbsp;Spring.Core;<br>
</span><span style="color: rgb(0, 0, 255);">using</span><span style="color: rgb(0, 0, 0);">&nbsp;Spring.Aop;<br>
</span><span style="color: rgb(0, 0, 255);">using</span><span style="color: rgb(0, 0, 0);">&nbsp;System;<br>
</span><span style="color: rgb(0, 0, 255);">using</span><span style="color: rgb(0, 0, 0);">&nbsp;Spring.Core;<br>
</span><span style="color: rgb(0, 0, 255);">using</span><span style="color: rgb(0, 0, 0);">&nbsp;Spring.Aop;<br>
</span><span style="color: rgb(0, 0, 255);">using</span><span style="color: rgb(0, 0, 0);">&nbsp;Spring.Context;<br>
</span><span style="color: rgb(0, 0, 255);">using</span><span style="color: rgb(0, 0, 0);">&nbsp;Spring.Context.Support;<br>
</span><span style="color: rgb(0, 0, 255);">namespace</span><span style="color: rgb(0, 0, 0);">&nbsp;OKEC.Sample.Spring<br>
{<br>
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;</span><span style="color: rgb(128, 128, 128);">&lt;summary&gt;</span><span style="color: rgb(0, 128, 0);"><br>
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;SpringFactory&nbsp;的摘要说明。<br>
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;</span><span style="color: rgb(128, 128, 128);">&lt;/summary&gt;</span><span style="color: rgb(128, 128, 128);"><br>
</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);">&nbsp;SpringContext<br>
&nbsp;&nbsp;&nbsp;&nbsp;{<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">&nbsp;SpringContext()<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">&nbsp;TODO:&nbsp;在此处添加构造函数逻辑<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 0);">//<br>
</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">private</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">static</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">bool</span><span style="color: rgb(0, 0, 0);">&nbsp;isInit&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">false</span><span style="color: rgb(0, 0, 0);">;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">private</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">static</span><span style="color: rgb(0, 0, 0);">&nbsp;IApplicationContext&nbsp;context;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">static</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">&nbsp;init()<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">string</span><span style="color: rgb(0, 0, 0);">[]&nbsp;xmlFiles&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">string</span><span style="color: rgb(0, 0, 0);">[</span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 0);">];&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;xmlFiles[</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">]&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">assembly://SpringSample/OKEC.Sample.Spring/Spring_bean.xml</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;context&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">&nbsp;XmlApplicationContext(xmlFiles);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;isInit&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">true</span><span style="color: rgb(0, 0, 0);">;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">static</span><span style="color: rgb(0, 0, 0);">&nbsp;IApplicationContext&nbsp;Context<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">get</span><span style="color: rgb(0, 0, 0);">{<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">(</span><span style="color: rgb(0, 0, 0);">!</span><span style="color: rgb(0, 0, 0);">isInit)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;init();<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">&nbsp;context;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>
&nbsp;&nbsp;&nbsp;&nbsp;}<br>
}<br>
</span></div>
<br>
<br>
<br>
<span style="font-size: 12pt; font-family: 宋体;"><strong>添加启动程序<br>
<br>
</strong><span style="font-size: 10.5pt; font-family: 'Times New Roman';" lang="EN">StartMain.cs<br>
<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; font-size: 13px; width: 98%; background-color: rgb(238, 238, 238);"><span style="color: rgb(0, 0, 255);">using</span><span style="color: rgb(0, 0, 0);">&nbsp;System;<br>
</span><span style="color: rgb(0, 0, 255);">namespace</span><span style="color: rgb(0, 0, 0);">&nbsp;OKEC.Sample.Spring<br>
{<br>
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;</span><span style="color: rgb(128, 128, 128);">&lt;summary&gt;</span><span style="color: rgb(0, 128, 0);"><br>
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;StartMain&nbsp;的摘要说明。<br>
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">&nbsp;</span><span style="color: rgb(128, 128, 128);">&lt;/summary&gt;</span><span style="color: rgb(128, 128, 128);"><br>
</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);">&nbsp;StartMain<br>
&nbsp;&nbsp;&nbsp;&nbsp;{<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">&nbsp;StartMain()<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);"><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">&nbsp;TODO:&nbsp;在此处添加构造函数逻辑<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 0);">//<br>
</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[STAThread]<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 0, 255);">static</span><span style="color: rgb(0, 0, 0);">&nbsp;</span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">&nbsp;Main()&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">Startup&nbsp;Spring&nbsp;Content</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SpringContext.init();<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">Test&nbsp;Spring&nbsp;IOC</span><span style="color: rgb(0, 128, 0);"><br>
</span><span style="color: rgb(0, 0, 0);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;HelloTest&nbsp;test&nbsp;</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">&nbsp;(HelloTest)SpringContext.Context.GetObject(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">Hello</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;test.Test();<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>
&nbsp;&nbsp;&nbsp;&nbsp;}<br>
}<br>
</span></div>
<br>
<br>
<br>
<span style="font-size: 12pt; font-family: 宋体;"><strong>运行程序<br>
<br>
</strong>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-indent: 21pt; line-height: 150%;"><span style="font-size: 12pt; line-height: 150%; font-family: 宋体;">结果为：<br>
</span></p>
<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; font-size: 13px; width: 98%; background-color: rgb(238, 238, 238);"><span style="color: rgb(0, 0, 0);">This&nbsp;</span><span style="color: rgb(0, 0, 255);">is</span><span style="color: rgb(0, 0, 0);">&nbsp;Spring.NET&nbsp;Sample&nbsp;Test</span><span style="color: rgb(0, 0, 0);">!</span><span style="color: rgb(0, 0, 0);"><br>
Please&nbsp;press&nbsp;Enter&nbsp;close&nbsp;the&nbsp;windows</span><span style="color: rgb(0, 0, 0);">!</span><span style="color: rgb(0, 0, 0);"><br>
</span></div>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-indent: 21pt; line-height: 150%;"><br>
<span style="font-size: 12pt; font-family: 宋体;">你的第一个<span lang="EN-US">Spring.NET</span>的程序成功了！</span><span lang="EN-US"><o:p><br>
<br>
<em><span style="color: rgb(128, 128, 128);">文档中的项目源代码请从以下地址下载：<br>
</span></em><a href="http://www.springframework.cn/read.php?fid=8&amp;tid=2&amp;toread=1"><span style="color: rgb(128, 128, 128);"><em>http://www.springframework.cn/read.php?fid=8&amp;tid=2&amp;toread=1</em></span></a><a href="http://www.springframework.cn/htm_data/8/0611/2.html"></a><br>
<em><span style="color: rgb(128, 128, 128);">完整的文档请下载PDF文档：<br>
</span></em><a href="http://www.springframework.cn/read.php?fid=2&amp;tid=1&amp;toread=1"><span style="color: rgb(128, 128, 128);"><em>http://www.springframework.cn/read.php?fid=2&amp;tid=1&amp;toread=1</em></span></a> </o:p></span></p></span><p></p>
</span></span></span></span></span></span>

<div id="digg_block">
<div id="div_digg">										
	<div class="diggit" onclick="DiggIt(579059,23118,1)"> 
		<span class="diggnum" id="digg_count_579059">1</span>
	</div>
	<div class="buryit" onclick="DiggIt(579059,23118,2)"> 
		<span class="burynum" id="bury_count_579059">0</span>
	</div>
	<div class="clear"></div>
	<span style="display: none;" id="span_isdigged_579059">0</span>	
	<div class="diggword" id="digg_word_579059">(请您对文章做出评价)</div>	
</div>
</div>
<div class="clear"></div>
<div id="post_next_prev">
<a href="http://www.cnblogs.com/it1630/archive/2006/12/01/578709.html">« </a> 上一篇：<a href="http://www.cnblogs.com/it1630/archive/2006/12/01/578709.html" title="发布于2006-12-01 11:11">实战C#.NET--Spring.NET &amp; NHibernate的整合</a><br>
<a href="http://www.cnblogs.com/it1630/archive/2006/12/01/579060.html">» </a> 下一篇：<a href="http://www.cnblogs.com/it1630/archive/2006/12/01/579060.html" title="发布于2006-12-01 15:27">C#.NET编程----Spring.NET &amp; NHibernate整合(二)</a><br>
</div>








		<p class="postfoot">
			posted on 2006-12-01 15:23 <a href="http://www.cnblogs.com/it1630/">㊣阿华</a> 阅读(8277) <a href="#commentform">评论(14)</a> &nbsp;<a href="http://www.cnblogs.com/it1630/admin/EditPosts.aspx?postid=579059">编辑</a> <a href="http://www.cnblogs.com/it1630/AddToFavorite.aspx?id=579059">收藏</a> <a href="#" onclick="PutInWz();return false;">网摘</a>  所属分类: <a href="http://www.cnblogs.com/it1630/category/77467.html">我的随笔</a>
		</p>
	</div>
	<img src="579059.html" height="1" width="1">
	
<!--
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
<rdf:Description
rdf:about="http://www.cnblogs.com/it1630/archive/2006/12/01/579059.html"
dc:identifier="http://www.cnblogs.com/it1630/archive/2006/12/01/579059.html"
dc:title=""
trackback:ping="http://www.cnblogs.com/it1630/services/trackbacks/579059.aspx" />
</rdf:RDF>
-->

	</div>
</div>
	<a name="pagedcomment"></a>
<div class="container">
	<div class="containerheader"><h3>View Comments</h3></div>	
	<div id="comments" class="containercontent">
		<span id="span_comment_maxid" style="display: none;">1373159</span>
		
				<div class="post">
					<h5>
						<a href="#579131">#1楼</a><a name="579131" id="comment_anchor_579131"></a>
						&nbsp;&nbsp;<a onclick='ReplyComment("henry",579131,"9PrJj5Aj7UgTal3giJxPrT478a7/2yObCrNWHdhf3DlkrDXS0IQszg==")' href="http://www.cnblogs.com/it1630/archive/2006/12/01/579059.html#commentform">回复</a>&nbsp;&nbsp;<a onclick='QuoteComment(579131,"9PrJj5Aj7UgTal3giJxPrT478a7/2yObCrNWHdhf3DlkrDXS0IQszg==")' href="http://www.cnblogs.com/it1630/archive/2006/12/01/579059.html#commentform">引用</a>&nbsp;&nbsp;<a title="查看该作者发表过的评论" href="http://www.cnblogs.com/CommentsByAuthor.aspx?author=henry" target="_top">查看</a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl00_DeleteLink" href="javascript:__doPostBack('Comments1$CommentList$ctl00$DeleteLink','')"></a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl00_EditLink"></a>
					</h5>
					<span id="comment_body_579131" class="blog_comment_body">没有用过Spring
<br>HelloTest test = (HelloTest)SpringContext.Context.GetObject("Hello");
<br>这种使用方式体现Spring的IOC运用感觉有很大问题，明确类型的引用不能体现反向依赖的好处；即使是入门的例子应该严紧一点好。</span>
					<div class="postfoot">
						2006-12-01 16:16 | <a id="Comments1_CommentList_ctl00_NameLink" href="http://www.cnblogs.com/henryfan/" target="_top">henry</a>&nbsp;<a href="http://space.cnblogs.com/msg/send/henry" title="给此人发送站内短消息" class="sendMsg2This">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a>
					</div>
				</div>
			
				<div class="post">
					<h5>
						<a href="#579153">#2楼</a><a name="579153" id="comment_anchor_579153"></a>[<span class="louzhu">楼主</span>]
						&nbsp;&nbsp;<a onclick='ReplyComment("㊣阿华",579153,"YLtdbFaTtGfx9UmHXuX9MD6PGd0GbhdQZuXECjd5Dd36EaSwTg+1jQ==")' href="http://www.cnblogs.com/it1630/archive/2006/12/01/579059.html#commentform">回复</a>&nbsp;&nbsp;<a onclick='QuoteComment(579153,"YLtdbFaTtGfx9UmHXuX9MD6PGd0GbhdQZuXECjd5Dd36EaSwTg+1jQ==")' href="http://www.cnblogs.com/it1630/archive/2006/12/01/579059.html#commentform">引用</a>&nbsp;&nbsp;<a title="查看该作者发表过的评论" href="http://www.cnblogs.com/CommentsByAuthor.aspx?author=%e3%8a%a3%e9%98%bf%e5%8d%8e" target="_top">查看</a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl01_DeleteLink" href="javascript:__doPostBack('Comments1$CommentList$ctl01$DeleteLink','')"></a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl01_EditLink"></a>
					</h5>
					<span id="comment_body_579153" class="blog_comment_body">HelloTest test = (HelloTest)SpringContext.Context.GetObject("Hello"); 
<br>这个是单次从SpringContext中取对像时使用的。
<br>
<br>在实际的开发中。程序不会频繁的调用SpringContext从容器中取对像。
<br>
<br>Spring只是一个容器，在C#做项目时，还需要一个架设在容器之上的框架。
<br>
<br>比如说，应该程序有一个入口程序，我们在程序中只会从容器取一次这个对像，其他的依赖的对像，容器会自动调用相关的SET方法给对像赋值(对像)。
<br>
<br></span>
					<div class="postfoot">
						2006-12-01 16:29 | <a id="Comments1_CommentList_ctl01_NameLink" href="http://www.cnblogs.com/it1630/" target="_top">㊣阿华</a>&nbsp;<a href="http://space.cnblogs.com/msg/send/%e3%8a%a3%e9%98%bf%e5%8d%8e" title="给此人发送站内短消息" class="sendMsg2This">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a>
					</div>
				</div>
			
				<div class="post">
					<h5>
						<a href="#579173">#3楼</a><a name="579173" id="comment_anchor_579173"></a>
						&nbsp;&nbsp;<a onclick='ReplyComment("henry",579173,"9PrJj5Aj7UgTal3giJxPrT478a7/2yObCrNWHdhf3DlkrDXS0IQszg==")' href="http://www.cnblogs.com/it1630/archive/2006/12/01/579059.html#commentform">回复</a>&nbsp;&nbsp;<a onclick='QuoteComment(579173,"9PrJj5Aj7UgTal3giJxPrT478a7/2yObCrNWHdhf3DlkrDXS0IQszg==")' href="http://www.cnblogs.com/it1630/archive/2006/12/01/579059.html#commentform">引用</a>&nbsp;&nbsp;<a title="查看该作者发表过的评论" href="http://www.cnblogs.com/CommentsByAuthor.aspx?author=henry" target="_top">查看</a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl02_DeleteLink" href="javascript:__doPostBack('Comments1$CommentList$ctl02$DeleteLink','')"></a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl02_EditLink"></a>
					</h5>
					<span id="comment_body_579173" class="blog_comment_body">我所了解的IOC最主要的功能是实现反向依赖，通过配置实现良好的功能整合。
<br>HelloTest test = (HelloTest)SpringContext.Context.GetObject("Hello"); 
<br>这句除了实现对象创建没有体现任何IOC的思想（从我的理解上），当修改配置文件这段代码必然会导致运行错误；既然这样那IOC无缝整合的思想又体现在那里?
<br>可能是我对IOC的理解错误，请楼主指证!
<br></span>
					<div class="postfoot">
						2006-12-01 16:42 | <a id="Comments1_CommentList_ctl02_NameLink" href="http://www.cnblogs.com/henryfan/" target="_top">henry</a>&nbsp;<a href="http://space.cnblogs.com/msg/send/henry" title="给此人发送站内短消息" class="sendMsg2This">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a>
					</div>
				</div>
			
				<div class="post">
					<h5>
						<a href="#579484">#4楼</a><a name="579484" id="comment_anchor_579484"></a>
						&nbsp;&nbsp;<a onclick='ReplyComment("Zane",579484,"")' href="http://www.cnblogs.com/it1630/archive/2006/12/01/579059.html#commentform">回复</a>&nbsp;&nbsp;<a onclick='QuoteComment(579484,"")' href="http://www.cnblogs.com/it1630/archive/2006/12/01/579059.html#commentform">引用</a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl03_DeleteLink" href="javascript:__doPostBack('Comments1$CommentList$ctl03$DeleteLink','')"></a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl03_EditLink"></a>
					</h5>
					<span id="comment_body_579484" class="blog_comment_body">建议楼上的看看Spring.Net的入门文档，单就IOC来说，Spring.Net的确不如Castle的好用。如果从框架来说，如对WebService，RemotingService，dll的支持以及结构清晰度来说，还是Spring.Net更胜一筹。</span>
					<div class="postfoot">
						2006-12-01 23:21 | <a id="Comments1_CommentList_ctl03_NameLink" target="_blank">Zane[未注册用户]</a>
					</div>
				</div>
			
				<div class="post">
					<h5>
						<a href="#579792">#5楼</a><a name="579792" id="comment_anchor_579792"></a>
						&nbsp;&nbsp;<a onclick='ReplyComment("wqxh",579792,"13MjmF78Y8Qwq7P9D583JyIaxWjWcR3q6DjeakvhyuEqn8ZZKeJc4w==")' href="http://www.cnblogs.com/it1630/archive/2006/12/01/579059.html#commentform">回复</a>&nbsp;&nbsp;<a onclick='QuoteComment(579792,"13MjmF78Y8Qwq7P9D583JyIaxWjWcR3q6DjeakvhyuEqn8ZZKeJc4w==")' href="http://www.cnblogs.com/it1630/archive/2006/12/01/579059.html#commentform">引用</a>&nbsp;&nbsp;<a title="查看该作者发表过的评论" href="http://www.cnblogs.com/CommentsByAuthor.aspx?author=wqxh" target="_top">查看</a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl04_DeleteLink" href="javascript:__doPostBack('Comments1$CommentList$ctl04$DeleteLink','')"></a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl04_EditLink"></a>
					</h5>
					<span id="comment_body_579792" class="blog_comment_body">对于正在的项目，确实要使用反射来达到使用XML配置的效果，但作为讲解Spring.Net入门的讲解，楼主这样的用法也是很简洁恰到的，起码我了解了Spring.Net的基本使用方法。</span>
					<div class="postfoot">
						2006-12-02 13:47 | <a id="Comments1_CommentList_ctl04_NameLink" href="http://www.cnblogs.com/iceshare/" target="_top">wqxh</a>&nbsp;<a href="http://space.cnblogs.com/msg/send/wqxh" title="给此人发送站内短消息" class="sendMsg2This">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a>
					</div>
				</div>
			
				<div class="post">
					<h5>
						<a href="#956695">#6楼</a><a name="956695" id="comment_anchor_956695"></a>
						&nbsp;&nbsp;<a onclick='ReplyComment("高海东",956695,"cml17CWj2ddfUnadM4Vy4cKviFrrp4DZG7GHurnmQGZ8UBMILukkWQ==")' href="http://www.cnblogs.com/it1630/archive/2006/12/01/579059.html#commentform">回复</a>&nbsp;&nbsp;<a onclick='QuoteComment(956695,"cml17CWj2ddfUnadM4Vy4cKviFrrp4DZG7GHurnmQGZ8UBMILukkWQ==")' href="http://www.cnblogs.com/it1630/archive/2006/12/01/579059.html#commentform">引用</a>&nbsp;&nbsp;<a title="查看该作者发表过的评论" href="http://www.cnblogs.com/CommentsByAuthor.aspx?author=%e9%ab%98%e6%b5%b7%e4%b8%9c" target="_top">查看</a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl05_DeleteLink" href="javascript:__doPostBack('Comments1$CommentList$ctl05$DeleteLink','')"></a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl05_EditLink"></a>
					</h5>
					<span id="comment_body_956695" class="blog_comment_body">以后有机会来学习</span>
					<div class="postfoot">
						2007-11-12 13:22 | <a id="Comments1_CommentList_ctl05_NameLink" href="http://www.cnblogs.com/ghd258/" target="_top">高海东</a>&nbsp;<a href="http://space.cnblogs.com/msg/send/%e9%ab%98%e6%b5%b7%e4%b8%9c" title="给此人发送站内短消息" class="sendMsg2This">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a>
					</div>
				</div>
			
				<div class="post">
					<h5>
						<a href="#1045712">#7楼</a><a name="1045712" id="comment_anchor_1045712"></a>
						&nbsp;&nbsp;<a onclick='ReplyComment("usabcd",1045712,"")' href="http://www.cnblogs.com/it1630/archive/2006/12/01/579059.html#commentform">回复</a>&nbsp;&nbsp;<a onclick='QuoteComment(1045712,"")' href="http://www.cnblogs.com/it1630/archive/2006/12/01/579059.html#commentform">引用</a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl06_DeleteLink" href="javascript:__doPostBack('Comments1$CommentList$ctl06$DeleteLink','')"></a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl06_EditLink"></a>
					</h5>
					<span id="comment_body_1045712" class="blog_comment_body">楼主的这个例子虽然简洁明了，从代码上没有错误，但是并没有真正展示出 Spring  所倡导的理念。以至于1楼的误解了。
<br>换句话说，Spring 不是这样用的。
<br>
<br>所谓IOC，简单的讲，就是由容器管理对象的实例，而不是由调用者来实例化被调用者。这样可以实现软件各个层次之间的松散耦合，从而提高软件的可扩展性和可维护性。
<br>
<br>这个例子需要做如下的改进：
<br>HelloTest 类需要实现一个接口IHelloTest，接口里面包含方法Test()。
<br>
<br>使用的时候应该使用接口，而不是实际的类.
<br>IHelloTest test = (IHelloTest)SpringContext.Context.GetObject("Hello");
<br>
<br>调用者无需关心真正的业务实现。只需要用到里面的方法。
<br>
<br>
<br>
<br>
<br>
<br></span>
					<div class="postfoot">
						2008-01-19 19:52 | <a id="Comments1_CommentList_ctl06_NameLink" target="_blank">usabcd[未注册用户]</a>
					</div>
				</div>
			
				<div class="post">
					<h5>
						<a href="#1077187">#8楼</a><a name="1077187" id="comment_anchor_1077187"></a>
						&nbsp;&nbsp;<a onclick='ReplyComment("jnono",1077187,"")' href="http://www.cnblogs.com/it1630/archive/2006/12/01/579059.html#commentform">回复</a>&nbsp;&nbsp;<a onclick='QuoteComment(1077187,"")' href="http://www.cnblogs.com/it1630/archive/2006/12/01/579059.html#commentform">引用</a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl07_DeleteLink" href="javascript:__doPostBack('Comments1$CommentList$ctl07$DeleteLink','')"></a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl07_EditLink"></a>
					</h5>
					<span id="comment_body_1077187" class="blog_comment_body">说的都是啥东西啊，<br>基于.NET框架反射一共写起来也没几行，为什么还整个<br>(IHelloTest)SpringContext.Context.GetObject("Hello"); <br>整体对象生命周期由.NET运行时管理，还整什么<br>由容器管理对象的实例<br><br><br>看样写的根本就不是spring.net的东西!</span>
					<div class="postfoot">
						2008-02-22 09:57 | <a id="Comments1_CommentList_ctl07_NameLink" target="_blank">jnono[未注册用户]</a>
					</div>
				</div>
			
				<div class="post">
					<h5>
						<a href="#1114256">#9楼</a><a name="1114256" id="comment_anchor_1114256"></a>
						&nbsp;&nbsp;<a onclick='ReplyComment("莫小明",1114256,"")' href="http://www.cnblogs.com/it1630/archive/2006/12/01/579059.html#commentform">回复</a>&nbsp;&nbsp;<a onclick='QuoteComment(1114256,"")' href="http://www.cnblogs.com/it1630/archive/2006/12/01/579059.html#commentform">引用</a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl08_DeleteLink" href="javascript:__doPostBack('Comments1$CommentList$ctl08$DeleteLink','')"></a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl08_EditLink"></a>
					</h5>
					<span id="comment_body_1114256" class="blog_comment_body">大家别吵了.这只能谈是入门级的例子,谈不上spring.net的IOC反转控制.但是确实对我们的理解有所帮助,如果要做真正的IOC反转控制,当然少不了XML的配置,少不了接口编程,楼住只是想让我们更简单的理解,更有信心的入门,如果一来就搞的上5层模式,那估计没几个人看完就跑了.
<br>我所说的5层结构确实可以达到.那样可以做到良好的扩展性.........
<br>比如他的这个例子:
<br>(1)创建TestDao接口:
<br>   public interface TestDao{}
<br>(2)实现接口TestDaoImp:
<br> public class TestDaoImp implements TestDao
<br>{
<br>   //在这里往往需要创建数据库操作类
<br>  //例如:打个比方,MyConnection 数据库操作类........
<br>  private MyConnection conn;
<br> //这里会体现在XML的配置文件中.
<br>  public void setConn(MyConnection conn){this.conn=conn;}
<br>  //当然,做具体的数据库操作,Spring带有很多的持久层操作技术
<br>  //比如JdbcTemplate封装JDBC摸板类.
<br>}
<br>(3)创建业务层接口TestServiceDao:
<br> public interface  TestServiceDao {}
<br>(4)实现业务层接口TestServiceDaoImp:
<br>public class  TestServiceDaoImp implements TestServiceDao
<br>{
<br>    //往往会用到上面的TestDao接口,但是跟TestDaoImp 无关
<br>   private TestDao testDao;
<br>    //一定要做它的setXxx方法(具体会在XML中配置)
<br>    //其他代码...........
<br>}
<br>(5)创建真正的控制层(它只关心业务层接口TestServiceDao)
<br>public class  TestContral 
<br>{
<br>   //又来个TestServiceDao接口
<br>  //又必须在XML中配置相关信息
<br>  private  TestServiceDao testServiceDao;
<br>  //set它的方法
<br> //其他代码......... 
<br>}
<br> (6)最后是ASP.NET的页面或ASPX.CS的文件只管访问第五层,其他无需关心
<br>   当扩展时候.这是很不错的做法.............我的意见就这么多........呵呵.
<br>有兴趣的朋友一起讨论,,,,偶的QQ:272038088,这样的思想是我做JAVA几年所带来的,没什么新鲜........
<br></span>
					<div class="postfoot">
						2008-03-20 10:05 | <a id="Comments1_CommentList_ctl08_NameLink" rel="nofllow" href="http://www.cnitblog.com/r.aspx?url=http://www.24791.com" target="_top">莫小明[未注册用户]</a>
					</div>
				</div>
			
				<div class="post">
					<h5>
						<a href="#1202215">#10楼</a><a name="1202215" id="comment_anchor_1202215"></a>
						&nbsp;&nbsp;<a onclick='ReplyComment("usabcd",1202215,"")' href="http://www.cnblogs.com/it1630/archive/2006/12/01/579059.html#commentform">回复</a>&nbsp;&nbsp;<a onclick='QuoteComment(1202215,"")' href="http://www.cnblogs.com/it1630/archive/2006/12/01/579059.html#commentform">引用</a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl09_DeleteLink" href="javascript:__doPostBack('Comments1$CommentList$ctl09$DeleteLink','')"></a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl09_EditLink"></a>
					</h5>
					<span id="comment_body_1202215" class="blog_comment_body">8楼的，不懂就不要胡乱发言。
<br>等你搞清楚IOC是怎么回事了再发言不迟。</span>
					<div class="postfoot">
						2008-05-18 20:15 | <a id="Comments1_CommentList_ctl09_NameLink" target="_blank">usabcd[未注册用户]</a>
					</div>
				</div>
			
				<div class="post">
					<h5>
						<a href="#1296219">#11楼</a><a name="1296219" id="comment_anchor_1296219"></a>
						&nbsp;&nbsp;<a onclick='ReplyComment("steveds",1296219,"")' href="http://www.cnblogs.com/it1630/archive/2006/12/01/579059.html#commentform">回复</a>&nbsp;&nbsp;<a onclick='QuoteComment(1296219,"")' href="http://www.cnblogs.com/it1630/archive/2006/12/01/579059.html#commentform">引用</a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl10_DeleteLink" href="javascript:__doPostBack('Comments1$CommentList$ctl10$DeleteLink','')"></a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl10_EditLink"></a>
					</h5>
					<span id="comment_body_1296219" class="blog_comment_body">运行上面的程序怎么报错啊!
<br>未处理 Spring.Objects.Factory.ObjectDefinitionStoreException
<br>  Message="InputStream is null from Resource = [assembly [SpringSample, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null], resource [OKEC.Sample.Spring.Spring_bean.xml]]"
<br>  Source="Spring.Core"
<br>  ObjectName=""
<br>  ResourceDescription=""
<br>  StackTrace:
<br>       在 Spring.Objects.Factory.Xml.XmlObjectDefinitionReader.LoadObjectDefinitions(IResource resource)
<br>       在 Spring.Objects.Factory.Support.AbstractObjectDefinitionReader.LoadObjectDefinitions(String location)
<br>       在 Spring.Objects.Factory.Support.AbstractObjectDefinitionReader.LoadObjectDefinitions(String[] locations)
<br>       在 Spring.Context.Support.AbstractXmlApplicationContext.LoadObjectDefinitions(XmlObjectDefinitionReader objectDefinitionReader)
<br>       在 Spring.Context.Support.AbstractXmlApplicationContext.LoadObjectDefinitions(DefaultListableObjectFactory objectFactory)
<br>       在 Spring.Context.Support.AbstractXmlApplicationContext.RefreshObjectFactory()
<br>       在 Spring.Context.Support.AbstractApplicationContext.Refresh()
<br>       在 Spring.Context.Support.XmlApplicationContext..ctor(Boolean refresh, String name, Boolean caseSensitive, IApplicationContext parentContext, String[] configurationLocations)
<br>       在 Spring.Context.Support.XmlApplicationContext..ctor(String[] configurationLocations)
<br>       在 OKEC.Sample.Spring.SpringContext.init() 位置 C:\Documents and Settings\Owner\Local Settings\Application Data\Temporary Projects\SpringSample\SpringContext.cs:行号 28
<br>       在 OKEC.Sample.Spring.StartMain.Main() 位置 C:\Documents and Settings\Owner\Local Settings\Application Data\Temporary Projects\SpringSample\StartMain.cs:行号 19
<br>       在 System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
<br>       在 System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
<br>       在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
<br>       在 System.Threading.ThreadHelper.ThreadStart_Context(Object state)
<br>       在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
<br>       在 System.Threading.ThreadHelper.ThreadStart()
<br></span>
					<div class="postfoot">
						2008-08-24 16:39 | <a id="Comments1_CommentList_ctl10_NameLink" target="_blank">steveds[未注册用户]</a>
					</div>
				</div>
			
				<div class="post">
					<h5>
						<a href="#1315969">#12楼</a><a name="1315969" id="comment_anchor_1315969"></a>
						&nbsp;&nbsp;<a onclick='ReplyComment("NoText",1315969,"zmX5gh9iKquNZrzlFwi4mecqU+2h4Z1BuoOwXMJyZfAOt6UM1pQYXw==")' href="http://www.cnblogs.com/it1630/archive/2006/12/01/579059.html#commentform">回复</a>&nbsp;&nbsp;<a onclick='QuoteComment(1315969,"zmX5gh9iKquNZrzlFwi4mecqU+2h4Z1BuoOwXMJyZfAOt6UM1pQYXw==")' href="http://www.cnblogs.com/it1630/archive/2006/12/01/579059.html#commentform">引用</a>&nbsp;&nbsp;<a title="查看该作者发表过的评论" href="http://www.cnblogs.com/CommentsByAuthor.aspx?author=NoText" target="_top">查看</a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl11_DeleteLink" href="javascript:__doPostBack('Comments1$CommentList$ctl11$DeleteLink','')"></a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl11_EditLink"></a>
					</h5>
					<span id="comment_body_1315969" class="blog_comment_body">9楼太强了，无论dotnet还是java，思想是相通的</span>
					<div class="postfoot">
						2008-09-12 16:05 | <a id="Comments1_CommentList_ctl11_NameLink" href="http://www.cnblogs.com/notext/" target="_top">NoText</a>&nbsp;<a href="http://space.cnblogs.com/msg/send/NoText" title="给此人发送站内短消息" class="sendMsg2This">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a>
					</div>
				</div>
			
				<div class="post">
					<h5>
						<a href="#1373159">#13楼</a><a name="1373159" id="comment_anchor_1373159"></a><a name="Post"></a>
						&nbsp;&nbsp;<a onclick='ReplyComment("紫狼",1373159,"DhfqHI3QLPkXa8yrTHusgoEO7S+xspdj5KWgTZQ5StyOKLEFKRm3Og==")' href="http://www.cnblogs.com/it1630/archive/2006/12/01/579059.html#commentform">回复</a>&nbsp;&nbsp;<a onclick='QuoteComment(1373159,"DhfqHI3QLPkXa8yrTHusgoEO7S+xspdj5KWgTZQ5StyOKLEFKRm3Og==")' href="http://www.cnblogs.com/it1630/archive/2006/12/01/579059.html#commentform">引用</a>&nbsp;&nbsp;<a title="查看该作者发表过的评论" href="http://www.cnblogs.com/CommentsByAuthor.aspx?author=%e7%b4%ab%e7%8b%bc" target="_top">查看</a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl12_DeleteLink" href="javascript:__doPostBack('Comments1$CommentList$ctl12$DeleteLink','')"></a>&nbsp;&nbsp;<a id="Comments1_CommentList_ctl12_EditLink"></a>
					</h5>
					<span id="comment_body_1373159" class="blog_comment_body">垃圾
<br>鑒定完畢</span>
					<div class="postfoot">
						2008-11-18 09:56 | <a id="Comments1_CommentList_ctl12_NameLink" href="http://www.cnblogs.com/Zilang/" target="_top">紫狼</a>&nbsp;<a href="http://space.cnblogs.com/msg/send/%e7%b4%ab%e7%8b%bc" title="给此人发送站内短消息" class="sendMsg2This">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a>
					</div>
				</div>
			
	</div>
</div>

<div id="ctl04_comment_form" class="commentform">




<div id="ctl04_divLoginPannel">
<div class="login_tips">注册用户登录后才能发表评论，请 <a href="http://passport.cnblogs.com/login.aspx?ReturnUrl=http%3a%2f%2fwww.cnblogs.com%2fit1630%2farchive%2f2006%2f12%2f01%2f579059.html%3flogin%3d1%23commentform" class="underline">登录</a> 或 <a href="http://passport.cnblogs.com/register.aspx?ReturnUrl=http%3a%2f%2fwww.cnblogs.com%2fit1630%2farchive%2f2006%2f12%2f01%2f579059.html%23Bottom2" class="underline">注册</a> 。</div>
</div>

<div class="itnews c_ad_block" id="itnews">
<a href="http://news.cnblogs.com/" target="_top">IT新闻</a>:<br>

          ·  <a href="http://news.cnblogs.com/n/55129/" target="_top">雅虎或收购本地搜索和评论提供商Yelp</a><br>
	
          ·  <a href="http://news.cnblogs.com/n/55128/" target="_top">百度销售员工战黑回忆：电话声像战前冲锋号</a><br>
	
          ·  <a href="http://news.cnblogs.com/n/55127/" target="_top">苹果再度反击 要求ITC封杀诺基亚</a><br>
	
          ·  <a href="http://news.cnblogs.com/n/55126/" target="_top">【快乐周末】Google 最新产品： Google Toilet</a><br>
	
          ·  <a href="http://news.cnblogs.com/n/55125/" target="_top">纽约时报：Google与中国</a><br>
	
</div>


<div id="ad_under_comment" class="c_ad_block">
<a href="http://a4.yeshj.com/rd/34138/" target="_top">每天10分钟，轻松学英语</a><br><br>
<div id="google_ads_div_cnblogs_blogpost_bottom1">
<iframe src="index_2.html" style="border: 0pt none ;" marginheight="0" marginwidth="0" name="google_ads_iframe_cnblogs_blogpost_bottom1" id="google_ads_iframe_cnblogs_blogpost_bottom1" scrolling="no" frameborder="0" height="60" width="468"></iframe></div>

<br>
<div id="google_ads_div_cnblogs_blogpost_bottom">
<iframe src="index_3.html" style="border: 0pt none ;" marginheight="0" marginwidth="0" name="google_ads_iframe_cnblogs_blogpost_bottom" id="google_ads_iframe_cnblogs_blogpost_bottom" scrolling="no" frameborder="0" height="250" width="300"></iframe></div>

</div>
<div id="site_nav_under" class="c_ad_block">
网站导航：<br>
<a href="http://www.cnblogs.com/" target="_top">博客园首页</a> &nbsp;<a href="http://news.cnblogs.com/" target="_top">IT新闻</a> &nbsp;<a href="http://home.cnblogs.com/" target="_top">个人主页</a> &nbsp;<a href="http://home.cnblogs.com/ing/" target="_top">闪存</a> &nbsp;<a href="http://job.cnblogs.com/" target="_top">程序员招聘</a> &nbsp;<a href="http://space.cnblogs.com/" target="_top">社区</a> &nbsp;<a href="http://space.cnblogs.com/q/" target="_top">博问</a> &nbsp;<a href="http://wz.cnblogs.com/" target="_top">网摘</a>
</div>
<div id="ad_under_comment2" class="c_ad_block">
<a href="http://www.china-pub.com/STATIC07/0912/zh_ndcx_091212.asp" target="_top"><img src="chinapub_20091222.jpg" alt="" style="border: 0px none ;"></a><br>
<a href="http://www.china-pub.com/itbook/" target="_top">China-pub 计算机图书网上专卖店！6.5万品种2-8折！</a><br>
<a href="http://www.china-pub.com/static07/0901/zh_jueba_090121.asp" target="_top">China-Pub 计算机绝版图书按需印刷服务</a><br>
</div>

<div id="relative_search"><br><b>相关搜索:</b><br> <a href="http://zzk.cnblogs.com/s?w=%e6%88%91%e7%9a%84%e9%9a%8f%e7%ac%94" target="_top">我的随笔</a> </div><div id="relative_search"><br><b>在知识库中查看：</b><br> <a href="http://kb.cnblogs.com/a/579059/">C#.NET编程----Spring.NET &amp; NHibernate整合(一)</a></div>

</div>


				
		</div>
	</div>	
	<div class="clearing">&nbsp;</div>
</div>
<div id="footer">
	
Powered by:<br> 

<a id="Footer1_Hyperlink3" name="Hyperlink1" href="http://www.cnblogs.com/" style="font-family: Verdana; font-size: 12px;">博客园</a><br>
Copyright © ㊣阿华

</div>
    </form>
	
	
      
    
    
    
</body>
</html>
